<template>
  <div>
    <el-input v-model="bname" placeholder="请输入商品类别" style="width:170px;"></el-input>
    <el-input v-model="name" placeholder="请输入商品编码或者名称" style="width:170px;"></el-input>
    <el-button type="success" @click="getList()">查询</el-button>

    <el-table :data="tableData" border style="width: 100%">
      <el-table-column fixed prop="code" label="商品编码" width="150"></el-table-column>
      <el-table-column prop="name" label="姓名" width="150"></el-table-column>
      <el-table-column prop="bname" label="类别" width="150"></el-table-column>
      <el-table-column prop="model" label="型号" width="150"></el-table-column>
      <el-table-column prop="minNum" label="库存总量" width="150"></el-table-column>
      <el-table-column prop="inventoryQuantity" label="销售数" width="150"></el-table-column>
      <el-table-column prop="lastPurchasingPrice" label="上次进价" width="150"></el-table-column>
      <el-table-column prop="purchasingPrice" label="平均售价" width="150"></el-table-column>
      <el-table-column prop="sellingPrice" label="销售价" width="150"></el-table-column>
    </el-table>
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="pageNo"
      :page-sizes="[10, 20, 30]"
      :page-size="pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total"
    ></el-pagination>
  </div>
</template>

<script>
import axios from "axios";
export default {
  methods: {
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
      this.pageSize = val;
      this.getList();
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
      this.pageNo = val;
      this.getList();
    },
    getList() {
      var $this = this;
      this.axios({
        method: "post",
        url: "http://localhost:9999/biz/tGoods/getGoodsList",
        params: {
          pageNo: this.pageNo,
          pageSize: this.pageSize,
          bname: this.bname,
          name: this.name,
          access_token: localStorage.getItem("access_token")
        }
      }).then(function(res) {
        $this.tableData = res.data.obj.list;
        $this.total = res.data.obj.total;
      });
    }
  },
  data() {
    return {
      tableData: [],
      pageNo: 1,
      pageSize: 10,
      total: 10,
      name: "",
      bname: ""
    };
  },
  mounted() {
    this.getList();
  }
};
</script>
